<template>
    <div>
        <van-address-edit
  :area-list="areaList"
  show-delete
  show-set-default
  show-search-result
  :search-result="searchResult"
  :area-columns-placeholder="['请选择', '请选择', '请选择']"
  @save="onSave"
  @delete="onDelete"
  @change-detail="onChangeDetail(addressEditRef)"
/>
    </div>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  export default defineComponent({
    name:'trade'
  })
</script>
<script lang="ts" setup>
import { ref } from 'vue';
import type { AddressEditInstance } from 'vant';
import { areaList } from '@vant/area-data';
import { showToast } from 'vant';
import { useRouter } from 'vue-router';

const addressEditRef = ref<AddressEditInstance>();

addressEditRef.value?.setAddressDetail('');
const searchResult = ref([]);
const router=useRouter()
    const onSave = (content:any) => {
        router.push({
            
            name:'Order',
            params:{
                id:JSON.stringify(content)
            }
        })
    }
    const onDelete = async() => {
        await router.push('/shopcart')
    };
    const onChangeDetail = (val:any) => {
      if (val) {
        searchResult.value = [
          {
            name: '黄龙万科中心',
            address: '杭州市西湖区',
          }
        ]as any
      } else {
        searchResult.value = [];
      }
    };
</script>

<style lang="less" scoped>
</style>
